package org.raymond.iworks.study.basic.feature;

import java.util.stream.Collectors;
import java.util.stream.Stream;

public class JDK12Test {

    public void switchTest() {
        int value = 4;
        int num = switch (value) {
            case 1 -> 1;
            case 2 -> 2;
            case 3, 4 -> 3;
            case 5 -> 5;
            default -> -1;
        };
        System.out.println(num);
    }

    public void teeing(){
        Student s1 = new Student("raymond", 35, "male", 100);
        Student s2 = new Student("alva", 18, "female", 85.5f);
        Student s3 = new Student("alice", 19, "female", 91.5f);
        Student s4 = new Student("ann", 18, "female", 90);

        String teeingResult = Stream.of(s1, s2, s3, s4)
                .collect(Collectors.teeing(Collectors.averagingDouble(Student::score),
                        Collectors.summarizingDouble(Student::score),
                        (r1, r2)-> r1+":"+r2.getSum()));
        System.out.println("teeing: "+teeingResult);
    }
}